package com.woniuxy.controller;

import com.woniuxy.entity.RbacManager;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.RbacManagerService;
import com.woniuxy.service.RbacRoleService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/rbacManager")
public class RbacManagerController1 {
    @Autowired
    RbacManagerService rbacManagerService;
    @Autowired
    RbacRoleService rbacRoleService;

    @PostMapping("/manager")
    public ResponseEntity addOne(@RequestBody RbacManager rbacManager){
        return rbacManagerService.addOne(rbacManager);
    }
    @DeleteMapping("/manager/{id}")
    public ResponseEntity deleteOne(@PathVariable int id){
        return rbacManagerService.deleteOne(id);
    }


    @PutMapping("/manager")
    public ResponseEntity updateOne(@RequestBody RbacManager rbacManager){
        return rbacManagerService.updateOne(rbacManager);
    }
    @GetMapping("/manager/{id}")
    public ResponseEntity findOne(@PathVariable int id){
        return rbacManagerService.findOne(id);
    }


    //根据用户名和状态查询一个
    @PostMapping("/findUserByInput")
    public ResponseEntity findUserByInput(@RequestBody RbacManager rbacManager){
        return rbacManagerService.findUserByInput(rbacManager);
    }

    //查询所有
    @GetMapping("/findAll/{currentPage}/{pageSize}")
    public ResponseEntity findAll(@PathVariable int currentPage,@PathVariable int pageSize){
        System.out.println("findAll执行");
        return rbacManagerService.findAll(currentPage,pageSize);
    }

}
